package com.cb.kfc.service.impl;

import com.cb.kfc.dao.IFriendDao;
import com.cb.kfc.dao.IProductDao;
import com.cb.kfc.domain.Friend;
import com.cb.kfc.domain.Product;
import com.cb.kfc.service.IFriendService;
import com.cb.kfc.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FriendServiceImpl implements IFriendService {

    @Autowired
    private IFriendDao friendDao;

    @Override
    public List<Friend> findAll() throws Exception {
        return friendDao.findAll();
    }

    @Override
    public void save(Friend friend) throws Exception {
        friendDao.save(friend);
    }

    @Override
    public Integer deleteFriendById(String[] ids) {
        if (ids != null && ids.length > 0) {
            Integer integer = friendDao.deleteOF(ids);
            integer = friendDao.deleteMF(ids);
            integer = friendDao.deleteF(ids);
            return integer;
        }
        return 0;
    }

    @Override
    public Friend findOne(String id) {
        Friend friend = friendDao.findOne(id);
        return friend;
    }

    @Override
    public void update(Friend friend) {
        friendDao.update(friend);
    }

}
